/*
 $(window).load(function() {
 $('#slider').nivoSlider({
 effect: 'random',               // Specify sets like: 'fold,fade,sliceDown'
 slices: 15,                     // For slice animations
 boxCols: 8,                     // For box animations
 boxRows: 4,                     // For box animations
 animSpeed: 500,                 // Slide transition speed
 pauseTime: 3000,                // How long each slide will show
 startSlide: 0,                  // Set starting Slide (0 index)
 directionNav: false,             // Next & Prev navigation
 controlNav: false,               // 1,2,3... navigation
 controlNavThumbs: false,        // Use thumbnails for Control Nav
 pauseOnHover: true,             // Stop animation while hovering
 manualAdvance: false,           // Force manual transitions
 prevText: 'Prev',               // Prev directionNav text
 nextText: 'Next',               // Next directionNav text
 randomStart: false,             // Start on a random slide
 beforeChange: function(){},     // Triggers before a slide transition
 afterChange: function(){},      // Triggers after a slide transition
 slideshowEnd: function(){},     // Triggers after all slides have been shown
 lastSlide: function(){},        // Triggers when last slide is shown
 afterLoad: function(){}         // Triggers when slider has loaded
 });
 });
 */
$(document).ready(function() {
    $('.bxslider').bxSlider({
        auto: true,
        pager: false,
        controls: false,
        mode: 'fade',
        pause: 8000
    });

    $('.bxslider2').bxSlider({
        //minSlides: 3,
        maxSlides: 3,
        slideWidth: 225,
        slideMargin: 15,
        pager: false,
        nextSelector: '#slider-prev',
        prevSelector: '#slider-next',
        prevText: '<img class="right-arr" alt="right" src="images/right-arr.jpg">',
        nextText: '<img class="left-arr" alt="left" src="images/left-arr.jpg">'
    });

    $('.questions .question').click(function() {
        var $this = $(this).parent();
        if ($this.hasClass('open')) {
            $this.removeClass('open');
        } else {
            $this.addClass('open');
            $this.siblings().removeClass('open');
        }


    });
    
    $(".various").fancybox({
		maxWidth	: 800,
		maxHeight	: 600,
		fitToView	: false,
		width		: '70%',
		height		: '70%',
		autoSize	: false,
		closeClick	: false,
		openEffect	: 'none',
		closeEffect	: 'none'
	});
	
	$('.nav ul li').mouseenter(function(){
		$(this).find('ul').slideDown(300);
	}).mouseleave(function(){
		$(this).find('ul').slideUp('fast');
	});
});

function loadAjax(data, type, fn, success) {
    $.ajax({
        url: fn,
        type: type,
        data: data,
        dataType: 'JSON',
        success: success,
        error: function(errorThrown) {
            console.log(errorThrown);
        }

    });
}

function changeLang(lang) {
    var url = baseUrl+'switch-lang.php';
    loadAjax('lang=' + lang, 'GET', url , function(resp) {
        location.reload();   
    });
}

